def __action_impl(ctx):
    args = [ctx.outputs.out.path] + [f.path for f in ctx.files.chunks]

    ctx.actions.run(
        inputs = ctx.files.chunks,
        outputs = [ctx.outputs.out],
        arguments = args,
        progress_message = 'Output to %s' % ctx.outputs.out.short_path,
        executable = ctx.executable.cmd,
    )

execute = rule(
    implementation = __action_impl,
    attrs = {
        "chunks": attr.label_list(allow_files = True),
        "out": attr.output(mandatory = True),
        "cmd": attr.label(
            executable = True,
            cfg = "host",
            allow_files = True,
            default = Label("//action:action"),
        )
    }
)
